const connection = require("../db/connection");
const input = require("scanline");
const checkProductExist = require("../functions/checkProductExist");

async function delOne(){
    const name = await input("请输入你要删除的商品名称:");
    checkProductExist(name);

    connection.query("delete from product where 名称=?",[name],(error)=>{
        if (error){
            console.log("删除单个商品信息失败!",error);
            process.exit(1);
        }
        console.log("\033[33m已成功删除该商品信息!\033[0m");
    });
    connection.end();
}

module.exports = delOne;